<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>企业列表</title>
    <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="https://cdn.bootcss.com/bootstrap-validator/0.5.3/css/bootstrapValidator.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css">
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <link href="css/my.css" rel="stylesheet" type="text/css">
    <style>
        .listdatasection {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            -ms-flex: 1;
            flex: 1;
            background-color: #fff;
            -webkit-overflow-scrolling: touch;
            margin-top: 56px;
            background-color: white;
        }

    </style>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="dist/dropload.min.js"></script>
    <script type="text/javascript" src="js/my.js"></script>
    <script type="text/javascript">
        var isunfinishList = true;
        var listdata = [];
        var curPage = 1;
        var totalPage = 1;

        function switchlisttype() {
            var setl1 = "";
            var setl2 = "";
            if (isunfinishList) {
                setl1 = "#unfinishlabel";
                setl2 = "#finishlabel";
            } else {
                setl1 = "#finishlabel";
                setl2 = "#unfinishlabel";
            }
            $(setl1).removeClass("btn-primary");
            $(setl1).removeClass("active");
            $(setl1).addClass("btn-default");
            $(setl2).removeClass("btn-default")
            $(setl2).addClass("btn-primary");
            $(setl2).addClass("active");
            isunfinishList = !isunfinishList;
            toLoadList(isunfinishList);
        }

        function toLoadList(isfinish) {
            var ltype = 0;
            if (isfinish) {
                ltype = 1;
            }
            var me = null;
            if (dropload) me = dropload;
            doloadlist($("#searchbarTf").val(), 1, ltype, false, me);
        }

        function gotoEE(order) {
            window.location = "ee_u_nameapply.html?id="+order;
        }

        function searchbykey() {
            var thetype = 0;
            if (!isunfinishList) {
                thetype = 1;
            }
            var me = null;
            if (dropload) me = dropload;
            doloadlist($("#searchbarTf").val(), 1, thetype, true, me);
        }

        function doloadlist(skey = "", page = 1, ttype = 0, isappend = true, me = null) {
            $.ajax({　　
                type: "GET", //用POST方式传输
                　　dataType: "json", //数据格式:JSON
                　　url: 'json/ee_u_ncompanylist.json', //目标地址
                　　data: JSON.stringify({
                    page: page,
                    type: ttype,
                    key: skey
                }),
                　　error: function(XMLHttpRequest, textStatus, errorThrown) {},
                　　success: function(jsonObj) {
                    if (!jsonObj.resault) {
                        tatalPages = jsonObj.totalPage;
                        curPage = jsonObj.curPage;
                        if (jsonObj.lists) {
                            var result = "";
                            for (var i = 0; i < jsonObj.lists.length; i++) {
                                var node = jsonObj.lists[i];
                                result += '<a href="javascript:gotoEE(' +
                                    node["cid"] +
                                    ')" class="list-group-item my-list-item" style="text-align: left;">' +
                                    node["company"] +
                                    '<span class="badge mytextbadge">&nbsp;<i class="fa fa-angle-right" aria-hidden="true"></i></span></a>';
                            }
                            if(curPage==1){
                                listdata = jsonObj.lists;
                            }else{
                                listdata = listdata.concat(jsonObj.lists);
                            }
                        } else {
                            //droplist opration
                            if (me) {
                                // 锁定
                                me.lock();
                                // 无数据
                                me.noData();
                            }
                        }
                        if (isappend) {
                            $('#mycrews').append(result);
                        } else {
                            $('#mycrews').html(result);
                        }
                        if (me) {
                            me.resetload();
                        }
                    } else {
                        debugger;
                        alert("获取数据错误");
                    }
                }
            });
        }
        var dropload = null;
        $(document).ready(function() {
            dropload = $("#listdatasection").dropload({
                scrollArea: window,
                domUp: {
                    domClass: 'dropload-up',
                    domRefresh: '<div class="dropload-refresh"><i class="fa fa-arrow-down"></i>下拉刷新</div>',
                    domUpdate: '<div class="dropload-update"><i class="fa fa-arrow-up"></i>释放更新</div>',
                    domLoad: '<div class="dropload-load"><i class="fa fa-circle-o-notch fa-spin"></i>加载中...</div>'
                },
                domDown: {
                    domClass: 'dropload-down',
                    domRefresh: '<div class="dropload-refresh"><i class="fa fa-arrow-up"></i>上拉加载更多</div>',
                    domLoad: '<div class="dropload-load"><i class="fa fa-circle-o-notch fa-spin"></i>加载中...</div>',
                    domNoData: '<div class="dropload-noData">暂无数据</div>'
                },
                loadUpFn: function(me) {
                    var thetype = 0;
                    if (!isunfinishList) {
                        thetype = 1;
                    }
                    doloadlist($("#searchbarTf").val(), 1, thetype, false, me);
                },
                loadDownFn: function(me) {
                    var thetype = 0;
                    if (!isunfinishList) {
                        thetype = 1;
                    }
                    doloadlist($("#searchbarTf").val(), curPage + 1, thetype, true, me);
                }
            });
            //-----------获取第一页数据----------

            doloadlist("", 1, 0, false, dropload);
        });

    </script>
</head>

<body class="my-body">
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container" style="padding-top:5px;height:56px;">
            <div class="input-group">
                <input id="searchbarTf" type="text" class="form-control input-lg" placeholder="公司名查询"><span class="input-group-addon btn btn-primary" onclick="javascript:searchbykey()"><i class="fa fa-search" aria-hidden="true"></i></span>
            </div>
        </div>
    </nav>
    <div id="listdatasection" class="section my-topsection listdatasection text-center">
        <div class="container text-center">
            <div id="listswitchGroup" class="btn-group" data-toggle="buttons" onclick="javascript:switchlisttype()">
                <label id="unfinishlabel" class="btn btn-primary active">
                    <input type="radio" name="options" value="1"><div style="width:100px;">未完成</div></label>
                <label id="finishlabel" class="btn btn-default">
                    <input type="radio" name="options" value="2"><div style="width:100px;">已完成</div></label>
            </div>
        </div>
        <div class="container">
            <div id="mycrews" class="list-group my-gap-top">

            </div>
        </div>
    </div>

</body>

</html>
